<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div style="display: none"><script id="myEditorImageC" type="text/plain"></script></div>
<div class="pageContent">
	<form method="post" action="${rootUrl}/info/index-class<c:if test="${indexClass.id != 0 && indexClass.id != '' }">/${indexClass.id}</c:if>" class="pageForm required-validate" onsubmit="return saveCallBack(this);">
		<c:if test="${indexClass.id != 0 && indexClass.id != '' }"><input type="hidden" name="_method" value="put"></c:if>
		<input type="hidden" name="indexClass.id" value="${indexClass.id }">
		<div class="pageFormContent" layoutH="56">
			<p>
				<label>平台类别：</label>
				<select id="selPlateForm" name="indexClass.platform" onchange="getShowType(this)">
					<option <c:if test="${indexClass.platform == 1}">selected="selected"</c:if> value="1">h5</option>
					<option <c:if test="${indexClass.platform == 2}">selected="selected"</c:if> value="2">pc</option>
					<option <c:if test="${indexClass.platform == 3}">selected="selected"</c:if> value="3">app</option>
				</select>
			</p>
			<p>
				<label>展示类型：</label>
				<select id="selShowType"  name="indexClass.showType">
				</select>
			</p>
			<p>
				<label>标题：</label>
				<input type="text" name="indexClass.title" size="30" value="${indexClass.title }" />
			</p>
			<p>
				<label>排序：</label>
				<input type="text" name="indexClass.sort" size="30" value="${indexClass.sort }" />
			</p>
			<p>
				<label>数据类型：</label>
				<select class="combox" id="selCombox" name="indexClass.dataType" onchange="selChange(this)">
					<option value="${indexClass.dataType}">${indexDataType[indexClass.dataType]}</option>
					<c:forEach var="item" items="${indexDataType}">
					    <c:if test="${item.key!=8&&item.key!=9}">   
						<option value="${item.key}" <c:if test="${indexClass.dataType == item.key}">selected="selected"</c:if>>${item.value}</option>
						</c:if>
					</c:forEach>
				</select>
			</p>
			<p>
				<label>数据值：</label>
				<input type="hidden" name="data.id" id="dataId" value="${indexClass.dataId }" />
				<input type="text" name="data.name" id="dataName" readonly="readonly" value="${indexClass.dataName }" />
				<a class="btnLook" id="dataId_1" href="${rootUrl}/goods/goods/1/dialog" width="1320" height="720" lookupGroup="data">商品列表</a>
				<a class="btnLook" id="dataId_2" style="display: none;" href="${rootUrl}/goods/goods-class/1/showAll" width="800" height="720" lookupGroup="data">商品分类</a>
				<a class="btnLook" id="dataId_3" style="display: none;" href="${rootUrl}/goods/goods-class/1/showAll" width="800" height="720" lookupGroup="data">商品分类</a>
				<a class="btnLook" id="dataId_4" style="display: none;" href="${rootUrl}/info/article-class/1/showAll" width="800" height="720" lookupGroup="data">新闻分类</a>
				<a class="btnLook" id="dataId_5" style="display: none;" href="${rootUrl}/info/article/1/dialog" width="800" height="720" lookupGroup="data">新闻</a>
			    <a class="btnLook" id="dataId_6" style="display: none;" href="${rootUrl}/goods/type-class/1/dialog2" width="880" height="600" lookupGroup="data">商品类型</a>
				<a class="btnLook" id="dataId_7" style="display: none;" href="${rootUrl}/goods/brand-goods-class/1/dialog2" width="800" height="720" lookupGroup="data">品牌</a>
			</p>
			<p>
			<dl class="nowrap">
				<dt>图片：</dt>
				<dd style="width: 300px;">
				<input name="indexClass.image" id="IC" type="hidden" size="30" value="${indexClass.image }"/>
				<div class="imgContainer" >
				<a href="#" onclick="iFileUploader.upImg('IC','myEditorImageIC');"><img id="myEditorImageIC" src="${indexClass.image}" /></a>
				</div>
				</dd>
			</dl>
				
   		 </div>
    	<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button id="theSubmit" type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
			<c:if test=""></c:if>
		</div>
    </form>
    	
</div>
<script>
	var showTypeList = [];
	<c:forEach var="item" items="${showType}">   
		showTypeList.push("${item.key}"+"--"+"${item.value}");
	</c:forEach>
	var val = "${indexClass.showType}";
	var selShowType = document.getElementById("selShowType");
	var isHas = false;
	function getShowType(obj){
		selShowType.innerHTML = "";
		var plateValue = $(obj).val();
		for(i = 0;i<showTypeList.length;i++){
			var showType = showTypeList[i].split("--");
			if((showType[0] - plateValue*100<100) && (showType[0] - plateValue*100>0)){
				if(val == showType[0]){
					isHas = true;
				}
				selShowType.options.add(new Option(showType[1], showType[0]));
			}
		}
		if(isHas){
			$("#selShowType").val(val);
			isHas = false;
		}
	}
	getShowType(document.getElementById("selPlateForm"));
	var articleImageFolder = 2;
	iFileUploader.initImg("myEditorImageC","IC","myEditorImageIC",{imageFolder:articleImageFolder});
	function selChange(obj){
		var idpos = $(obj).val() == "3" ? "2" : $(obj).val();
		var ids = ["1","2","3","4","5","6","7"];
		for(i =0;i<ids.length;i++){
			if(ids[i] == idpos){
				$("#dataId_"+ids[i]).show();
			}else{
				$("#dataId_"+ids[i]).hide();
			}
		}
	}
	selChange($("#selCombox"));
	
	function saveCallBack(obj){
		$("#dataId").attr("name","indexClass.dataId");
		$("#dataName").attr("name","indexClass.dataName");
		return validateCallback(obj, newDialogAjaxDone);
	}
</script>